package com.boxue.bxaiagents.demo.invoke;

import jakarta.annotation.Resource;
import org.springframework.ai.chat.messages.AssistantMessage;
import org.springframework.ai.chat.model.ChatModel;
import org.springframework.ai.chat.prompt.Prompt;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

/**
 * @author: [dongliu]
 * @createTime: [2025/6/6 17:00]
 * @Description: [Spring AI 框架调用 AI 大模型]
 * @version: [v1.0]
 */
//@Component
public class SpringAIInvoke implements CommandLineRunner {

    @Resource
    private ChatModel dashscopeChatModel;

    @Override
    public void run(String... args) throws Exception {
        AssistantMessage assistantMessage = dashscopeChatModel.call(new Prompt("你好，我是拨雪"))
                .getResult()
                .getOutput();
        System.out.println(assistantMessage.getText());
    }
}
